package tk.mybatis.springboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.springboot.mapper.FeedbackMapper;
import tk.mybatis.springboot.mapper.UserMapper;
import tk.mybatis.springboot.model.Feedback;
import tk.mybatis.springboot.model.Message;
import tk.mybatis.springboot.model.Users;

/**
 * Created by  on 2017/4/12.
 */
@RestController
@RequestMapping("/feedback")
@Transactional
public class FeedbackController {

    @Autowired
    private FeedbackMapper feedbackMapper;

    @RequestMapping("/add")
    public Object add(Feedback obj){
        if(null == obj.getId()) {
            feedbackMapper.insertSelective(obj);
        }
        else{
            feedbackMapper.updateByPrimaryKeySelective(obj);
        }
        return new Message();
    }
    @RequestMapping("")
    public Object list(Feedback users){
        return new Message(feedbackMapper.select(users));
    }
    @RequestMapping("/delete/{id}")
    public Object delete(@PathVariable Integer id){
        feedbackMapper.deleteByPrimaryKey(id);
        return new Message();
    }


}
